#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
##############################################################################
#
#
#         ___           ___           ___           ___
#        /  /\         /  /\         /  /\         /  /\
#       /  /::\       /  /:/_       /  /:/_       /  /::\
#      /  /:/\:\     /  /:/ /\     /  /:/ /\     /  /:/\:\
#     /  /:/~/:/    /  /:/ /:/_   /  /:/ /::\   /  /:/~/:/
#    /__/:/ /:/___ /__/:/ /:/ /\ /__/:/ /:/\:\ /__/:/ /:/
#    \  \:\/:::::/ \  \:\/:/ /:/ \  \:\/:/~/:/ \  \:\/:/
#     \  \::/~~~~   \  \::/ /:/   \  \::/ /:/   \  \::/
#      \  \:\        \  \:\/:/     \__\/ /:/     \  \:\
#       \  \:\        \  \::/        /__/:/       \  \:\
#        \__\/         \__\/         \__\/         \__\/
#
#
#
#
#   This file is part of ReSP.
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#
#
#   (c) Giovanni Beltrame, Luca Fossati
#       Giovanni.Beltrame@esa.int fossati@elet.polimi.it
#
##############################################################################


import Options

def build(bld):


    # Generation of the testSlave library
    obj = bld.new_task_gen('cxx', 'cshlib')
    obj.source ='''
        testSlave.cpp
    '''
    obj.target = 'testSlave'
    obj.uselib = 'SYSTEMC_H TLM BOOST'
    obj.uselib_local = 'systemc'

    # Generation of the testSlave wrapper extension
    obj = bld.new_task_gen('pypp')
    obj.source ='''
        testSlave.hpp
    '''
    obj.target = 'testSlave_wrapper'
    obj.uselib = 'SYSTEMC_H TLM BOOST BOOST_PYTHON'
    obj.uselib_local = 'systemc testSlave'
    obj.include = 'scwrapper tlmwrapper'
    obj.start_decls = 'testSlave'
    obj.custom_code = """
# Exclude protected members
cls = mb.global_ns.calldefs( declarations.access_type_matcher_t( 'protected' ) , allow_empty=True )
if cls: cls.exclude()
"""


    # Generation of the testMaster library
    obj = bld.new_task_gen('cxx', 'cshlib')
    obj.source ='''
        testMaster.cpp
    '''
    obj.target = 'testMaster'
    obj.uselib = 'SYSTEMC_H TLM BOOST'
    obj.uselib_local = 'systemc'

    # Generation of the testMaster wrapper extension
    obj = bld.new_task_gen('pypp')
    obj.source ='''
        testMaster.hpp
    '''
    obj.target = 'testMaster_wrapper'
    obj.uselib = 'SYSTEMC_H TLM BOOST PYEXT BOOST_PYTHON'
    obj.uselib_local = 'systemc testMaster'
    obj.include = 'scwrapper tlmwrapper'
    obj.start_decls = 'testMaster'
    obj.custom_code = """
# Exclude protected members
cls = mb.global_ns.calldefs( declarations.access_type_matcher_t( 'protected' ) , allow_empty=True )
if cls: cls.exclude()
"""

    # Generation of the irqGenerators wrapper extension
    obj = bld.new_task_gen('pypp')
    obj.source ='''
        irqGenerator.hpp
    '''
    obj.target = 'irqGenerator_wrapper'
    obj.uselib = 'SYSTEMC_H TLM BOOST PYEXT BOOST_PYTHON'
    obj.uselib_local = 'systemc'
    obj.include = 'scwrapper tlmwrapper'
    obj.start_decls = 'IrqGenerator'
    obj.custom_code = """
# Exclude protected members
cls = mb.global_ns.calldefs( declarations.access_type_matcher_t( 'protected' ) , allow_empty=True )
if cls: cls.exclude()
"""

    # Generation of the irqGenerators wrapper extension
    obj = bld.new_task_gen('pypp')
    obj.source ='''
        mytimer.hpp
    '''
    obj.target = 'timer_wrapper'
    obj.uselib = 'SYSTEMC_H TLM BOOST PYEXT BOOST_PYTHON'
    obj.uselib_local = 'systemc'
    obj.include = 'scwrapper tlmwrapper'
    obj.start_decls = 'MyTimer'
    obj.custom_code = """
# Exclude protected members
cls = mb.global_ns.calldefs( declarations.access_type_matcher_t( 'protected' ) , allow_empty=True )
if cls: cls.exclude()
"""
